<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title th:text="${questionDTO.title}"></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <!--引入bootstrap的css样式-->
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <!--自定义css样式-->
    <link rel="stylesheet" href="/css/community.css">
    <!--markdown css-->
    <link rel="stylesheet" href="/css/editormd.preview.css" />
    <!--引入jQuery库 js样式才能生效-->
    <script src="/js/jquery-3.4.1.min.js"></script>
    <!--bootstrap js type="application/javascript"记得加上-->
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/community.js" type="application/javascript"></script>
    <script src="/js/moment.js" type="application/javascript"></script>
    <!--markdown js-->
    <script src="/js/editormd.js" type="application/javascript"></script>
    <script src="/js/lib/marked.min.js" type="application/javascript"></script>
    <script src="/js/lib/prettify.min.js" type="application/javascript"></script>
</head>
<body>
<!--导航栏-->
<div th:insert="~{navigation.html :: nav}"></div>
<!--流式布局容器-->
<div class="container-fluid main profile">

    <div class="row">
        <!--左半部分-->
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <!--正文-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h2><span th:text="${questionDTO.title}" class="question-title"></span></h2>
                <span class="text-color-999">
                作者:  <span th:text="${questionDTO.user.name}"></span> |
                发布时间:  <span th:text="${#dates.format(questionDTO.gmtCreate,'yyyy-MM-dd HH:mm')}"></span> |
                阅读数:  <span th:text="${questionDTO.viewCount==null?0:questionDTO.viewCount}"></span>
                </span>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <!--内容-->
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="question-markdown-view" >
                    <!-- Server-side output Markdown text -->
                    <textarea style="display:none;" th:text="${questionDTO.description}"></textarea>
                </div>
                <script type="text/javascript">
                    $(function() {
                        editormd.markdownToHTML("question-markdown-view", {});
                    });
                </script>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <!--标签-->
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <span  class="label label-info question-tag" th:each="tag:${questionDTO.tag.split(',')}">
                        <span class="glyphicon glyphicon-tags"></span>
                        <span class="label label-info" th:text="${tag}"></span>
                    </span>
                </div>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <!--编辑   当用户登录并且问题是用户发布才能编辑-->
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <a th:href="@{'/publish/'+${questionDTO.id}}" class="edit"
                       th:if="${session.user!=null && session.user.id==questionDTO.creator}">
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true">编辑</span>
                    </a>
                </div>

            </div>

            <!--回复-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <!--回复数-->
                <h3><span th:text="${questionDTO.commentCount==null?0:questionDTO.commentCount}"></span> 个回复</h3>
                <!--回复内容-->
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comments" th:each="comment:${comments}">
                    <div class="media">
                        <!--头像-->
                        <div class="media-left">
                            <a href="#"><img class="media-object img-rounded" th:src="@{${comment.user.avatarUrl}}"></a>
                        </div>
                        <!--用户名-->
                        <div class="media-body media-comment" th:id="'comment-body-'+comment.id">
                            <h4 class="media-heading"><span th:text="${comment.user.name}"></span></h4>
                        </div>
                        <!--回复内容-->
                        <div th:text="${comment.content}" style="margin-left: 45px"></div>
                        <!--图标和日期信息-->
                        <div class="menu">
                            <span class="glyphicon glyphicon-thumbs-up icon" aria-hidden="true"></span>
                            <span class="icon">
                                 <span class="glyphicon glyphicon-comment" aria-hidden="true"
                                       th:data-id="${comment.id}" onclick="collapseComments(this)"></span>
                                 <span th:text="${comment.commentCount}"></span>
                            </span>

                            <span class="pull-right" th:text="${#dates.format(comment.gmtCreate,'yyyy-MM-dd')}"></span>
                        </div>
                        <!--二级评论-->
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 collapse sub-comment"
                             th:id="${'comment-'+comment.id}">

                            <!--评论框-->
                            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                                <input type="text" class="form-control" placeholder="评论一下..."
                                       th:id="'input-'+${comment.id}">
                                <button type="button" class="btn btn-success pull-right" th:data-id="${comment.id}"
                                        onclick="comment(this)">评论
                                </button>
                            </div>
                        </div>
                        <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 commnet-hr">
                    </div>
                </div>
            </div>
        </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <h3><span>提交回复</span></h3>
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp">
            <!--回复输入框-->
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="comment_section">
                <!--头像-->
                <div class="media-left">
                    <a href="#">
                        <img class="media-object img-rounded" th:src="${session.user!=null?session.user.avatarUrl:'/images/default-avatar.png'}">
                    </a>
                </div>
                <!--用户名-->
                <div class="media-left media-comment">
                    <h5>
                        <span th:text="${session.user!=null?session.user.name:'匿名用户'}"></span>
                    </h5>
                </div>
                <!--用户id-->
                <input type="hidden" th:value="${questionDTO.id}" id="question_id">
                <!--评论内容-->
                <textarea class="form-control text-comment" rows="6" id="text-comment"></textarea>
                <!--回复按钮-->
                <button type="button" class="btn btn-success btn-comment" onclick="post()">回复</button>
            </div>
        </div>
        </div>
        <!--右半部分-->
        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">

            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3>发起人</h3>
                <div class="media-left">
                    <a href="#"><img class="media-object img-rounded" th:src="@{${questionDTO.user.avatarUrl}}"></a>
                </div>
                <div class="media-left">
                    <h5><span th:text="${questionDTO.user.name}"></span></h5>
                </div>
            </div>

            <!--微信号-->
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="margin-top: 9px;">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3 style="margin-top: 0px;">关注站长微信</h3>
                <img src="/images/wechat.png" class="img-thumbnail question-wechat">
            </div>

            <!--相关问题-->
            <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3 style="margin-top: 0px;">相关问题</h3>
                <ul class="question-related">
                    <li th:each="related:${questionDTOList}"><a th:href="@{'/question/'+${related.id}}" th:text="${related.title}"></a></li>
                </ul>

            </div>
        </div>
    </div>

</div>
<!--页尾-->
<div th:insert="~{foot.html :: foot}"></div>
</body>
</html>